var SplashScreen={
	Init:function()
	{
		this.main = document.createElement('div');
		this.main.className="SplashLoading";
		this.main.innerHTML ='<img src="images/bigrotation2.gif"/>';
		this.progress = document.createElement('div');
		this.progress.className="SplashPr";
		this.main.appendChild(this.progress);
		$('#page_content').append(this.main);
		this.LoadScript();
	},
	Destroy:function()
	{
		SplashScreen.EndCallback();
		$(this.main).remove();
	},
	Update:function(index)
	{
		this.progress.innerHTML=(index / this.ScriptList.length * 100).toFixed(0)+"%";
	},
	Step:5,
	LoadScript:function()
	{
		var list = this.ScriptList;
		var index = 0;
//		var head = document.getElementsByTagName("head")[0];
		var head =$('head');
		var loadCallback = 
		function onLoad()
		{
			var count = SplashScreen.Step;
			while (count > 0)
			{
				if (index >= list.length) {
					SplashScreen.Destroy();
					return;
				}
				//jQuery.getScript(list[index]);
				head.append('<script type="text/javascript" src="'+list[index]+'"></script>')
				index++;
				count--;
			}
			SplashScreen.Update(index);
			setTimeout(loadCallback,0);
		}
		SplashScreen.Update(index);
		setTimeout(loadCallback,0);
	},
	ScriptList :['scripts/plugins/ui/jquery.ui.all.packed.js',
		'scripts/plugins/colorpicker/colorpicker.js',
		
		//'scripts/engine/jsForms.design.js',
		'scripts/engine/jsForms.design.file.js',

		'scripts/templates/progressBar.js',
		'scripts/templates/componentEditor.js',
		'scripts/templates/slider.js',
		'scripts/templates/button.js',
		'scripts/templates/menu.js',
		'scripts/templates/listbox.js',
		'scripts/templates/expander.js',
		'scripts/templates/treeView.js',
		'scripts/templates/propertyItem.js',
		'scripts/templates/tabControl.js',
		'scripts/templates/cssConfig.js',
		'scripts/templates/sourceEditor.js',
		'scripts/templates/window.js',
		'scripts/templates/peConfig.js',
		'scripts/templates/domConfig.js',
		'scripts/templates/filesConfig.js',
		'scripts/templates/backgroundShadow.js',
		'scripts/templates/dialogEditComponent.js',
		'scripts/templates/infoConfig.js',
		'scripts/templates/highlightElement.js',
		'scripts/templates/insertComponentDialog.js',
		'scripts/templates/dialogNewComponent.js',
		'scripts/templates/insertCSSDialog.js',
		
		'scripts/components/progressBar.js',
		'scripts/components/componentEditor.js',
		'scripts/components/componentDesignDock.js',
		'scripts/components/slider.js',
		'scripts/components/button.js',
		'scripts/components/menu.js',
		'scripts/components/listbox.js',
		'scripts/components/expander.js',
		'scripts/components/treeView.js',
		'scripts/components/propertyItem.js',
		'scripts/components/tabControl.js',
		'scripts/components/cssConfig.js',
		'scripts/components/sourceEditor.js',
		'scripts/components/window.js',
		'scripts/components/peConfig.js',
		'scripts/components/domConfig.js',
		'scripts/components/filesConfig.js',
		'scripts/components/testComponent.js',
		'scripts/components/backgroundShadow.js',
		'scripts/components/dialogEditComponent.js',
		'scripts/components/infoConfig.js',
		'scripts/components/colorPicker.js',
		'scripts/components/highlightElement.js',
		'scripts/components/insertComponentDialog.js',
		'scripts/components/openFileControl.js',
		'scripts/components/dialogNewComponent.js',
		'scripts/components/insertCSSDialog.js',
		
		'scripts/templates/jsFormEditor.js',
		'scripts/components/jsFormEditor.js']
		
};

SplashScreen.EndCallback = createGUI;

function loadScripts()
{
	SplashScreen.Init();
};

$(document).ready(loadScripts);
